/** @format */

import { Routes, Route } from 'react-router-dom'

// 自定义路由组件
import CustomRouter from './components/CustomRouter/CustomRouter'

// 一级路由
import Layout from '@/layout/Layout'
import Login from '@/pages/Login/Login'
import Setting from '@/pages/Profile/Setting'

// 二级路由
import Home from '@/pages/Home/Home'
import Qa from '@/pages/Qa/Qa'
import Video from '@/pages/Video/Video'
import Profile from '@/pages/Profile/Profile'

import history from './utils/history'

import './App.scss'
import AuthRoute from './components/AuthRoute/AuthRoute'
import ArticleDetail from './pages/ArticleDetail/ArticleDetail'
import Search from './pages/Search/Search'
import List from './pages/Search/List/List'

function App() {
  return (
    <CustomRouter history={history}>
      <div className='app'>
        <Routes>
          {/* Layout架子 */}
          <Route
            path='/'
            element={<Layout />}>
            <Route
              index
              element={<Home />}
            />
            <Route
              path='qa'
              element={<Qa />}
            />
            <Route
              path='video'
              element={<Video />}
            />
            <Route element={<AuthRoute />}>
              <Route
                path='profile'
                element={<Profile />}
              />
            </Route>
          </Route>
          {/* Login */}
          <Route
            path='/login'
            element={<Login />}
          />
          <Route
            path='/profile/setting'
            element={
              <AuthRoute>
                <Setting />
              </AuthRoute>
            }
          />
          {/* 文章详情 */}
          <Route
            path='/article/:id'
            element={<ArticleDetail />}
          />
          {/* 搜索 */}
          <Route
            path='/search'
            element={<Search />}
          />
          {/* 搜索列表 */}
          <Route
            path='/search/:txt'
            element={<List />}
          />
        </Routes>
      </div>
    </CustomRouter>
  )
}

export default App
